if(DEFINED DEFOLD_POST_PROJECT_CMAKE_INCLUDED)
  return()
endif()
set(DEFOLD_POST_PROJECT_CMAKE_INCLUDED ON)

defold_log("defold_post_project.cmake:")

set(_cfg_list Release RelWithDebInfo MinSizeRel)
foreach(_cfg IN LISTS _cfg_list)
  string(TOUPPER "${_cfg}" _CFG_UP)
  foreach(_lang IN LISTS DEFOLD_LANGUAGE_LIST)
    set(_cache_var "CMAKE_${_lang}_FLAGS_${_CFG_UP}")
    if(DEFINED ${_cache_var})
      set(_flags "${${_cache_var}}")
      string(REPLACE "-DNDEBUG" "" _flags "${_flags}")
      string(REPLACE "/DNDEBUG" "" _flags "${_flags}")
      string(REGEX REPLACE "  +" " " _flags "${_flags}")
      string(STRIP "${_flags}" _flags)
      if(NOT _flags STREQUAL "${${_cache_var}}")
        set(${_cache_var} "${_flags}" CACHE STRING "${_cache_var}" FORCE)
        defold_log("defold_post_project: scrubbed -DNDEBUG from ${_cache_var}")
      endif()
    endif()
  endforeach()
endforeach()
